package server.model.solver.maze;

import server.model.solver.maze.algorithms.*;

public class MazeAction implements IAction {
	private int x;
	private int y;

	public MazeAction(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public State doAction(State state) {
		MazeState mazeState = (MazeState)state;
		MazeState newState = new MazeState(x, y);
		
		newState.addToX(mazeState.getX());
		newState.addToY(mazeState.getY());

		return newState;
	}
	
	public int getName() {
		if (x == 0 && y == 1) {
			return 2;
		}
		else if (x == 0 && y == -1) {
			return 1;
		}
		else if (x == 1 && y == 0) {
			return 4;
		}
		else if (x == -1 && y == 0) {
			return 3;
		}
		else if (x == 1 && y == 1) {
			return 7;
		}
		else if (x == 1 && y == -1) {
			return 5;
		}
		else if (x == -1 && y == 1) {
			return 8;
		}
		else if (x == -1 && y == -1) {
			return 6;
		}
		// Never going to happen!
		else {
			return 0;
		}
	}
}
